import 'package:flutter/material.dart';
import '../../helper/Helper.dart';
import '../../model/daydata.dart';
import '../../model/scqx_r.dart';
import '../../model/scsq_q.dart';
import '../../model/scsq_sk.dart';
import '../../model/scsq_z.dart';
import '../../widgets/TimeLinePanel.dart';
import '../../widgets/inputWidget.dart';

class SdzxHelper {
  static String meetRecord = "36bb3015-d046-4923-bc33-8f77fa168a2a";
  static String researchRecord = "17154929-a60b-436d-9e2e-f7da525c9c67";
  static String zhibanRecord = "65d13852-d467-4f65-8f56-558d743ba600";
  static String flagRecord = "f92de602-1799-4f67-af16-da9ba7e7ff21";
  static String projectRecord = "fc3ea778-1e13-4408-840e-f3dd20b1ca70";
  static String floodRecord = "50c7c0a4-da10-4711-b36f-ea00515cf9ac";
  static String gonghuiRecord = "adb8aad2-e3b1-45af-a94d-e0662f4fa758";

  static Widget getQTimeLine(List<ScsqQ> qList) {
    List<String> tList = <String>[];
    List<double> vList = <double>[];
    int nn = 0;

    for (var a in qList) {
      if (a.Q != -1) {
        tList.add(Helper.DateTimeFormat4(a.TM));
        vList.add(a.Q);
        nn++;
      }
    }
    // print(vList);
    return TimeLinePanel(
        qList.first.STNM + "站流量过程线", tList, vList, nn, 0, "m3/s");
  }

  static Widget getZTimeLine(List<ShuiZhi> zList, String cs) {
    List<String> tList = <String>[];
    List<double> vList = <double>[];
    String dw = "-";

    for (var a in zList) {
      tList.add(Helper.DateTimeFormat5(a.PUBLISHTIME));

      switch (cs) {
        case "水质标准":
          vList.add(getSZBZ(a.CWQI));
          dw = "类";
          break;
        case "高锰酸盐":
          vList.add(Helper.GetDouble(a.COL3));
          dw = "mg/L";
          break;
        case "氨氮":
          vList.add(Helper.GetDouble(a.COL2));
          dw = "mg/L";
          break;
        case "总磷":
          vList.add(Helper.GetDouble(a.COL1));
          dw = "mg/L";
          break;
        case "浊度":
          vList.add(Helper.GetDouble(a.COL14));
          dw = "NTU";
          break;
        case "PH值":
          vList.add(Helper.GetDouble(a.COL11));
          dw = "无量纲";
          break;
        case "总氮":
          vList.add(Helper.GetDouble(a.COL19));
          dw = "mg/L";
          break;
        case "溶解氧":
          vList.add(Helper.GetDouble(a.COL6));
          dw = "mg/L";
          break;
      }
    }
    // print(vList);
    return TimeLinePanel("库区" + cs + "过程线", tList, vList, zList.length, 2, dw);
  }

  static double getSZBZ(String s1) {
    if (s1 == "I") return 1;
    if (s1 == "II") return 2;
    if (s1 == "III") return 3;
    if (s1 == "IV") return 4;
    if (s1 == "V") return 5;
    return 0;
  }

  static Widget getSKTimeLine1(List<ScsqSK> zList, String cs) {
    List<String> tList = <String>[];
    List<double> vList = <double>[];
    String dw = "-";
    for (var a in zList) {
      tList.add(Helper.DateTimeFormat4(a.TM));
      switch (cs) {
        case "水库水位":
          vList.add(a.H);
          dw = "m";
          break;
        case "入库流量":
          vList.add(a.R);
          dw = "m3/s";
          break;
        case "出库流量":
          vList.add(a.Q);
          dw = "m3/s";
          break;
      }
    }
    // print(vList);
    return TimeLinePanel(cs + "过程线", tList, vList, zList.length, 2, dw);
  }

  static List<String> RainList() {
    var xx = <String>[];
    xx.add("1小时累计值");
    xx.add("6小时累计值");
    xx.add("12小时累计值");
    xx.add("24小时累计值");
    xx.add("48小时累计值");
    xx.add("72小时累计值");
    return xx;
  }

  static double getRainVal(ScqxR x1, String cs) {
    switch (cs) {
      case "1小时累计值":
        return x1.pr1;
        break;
      case "6小时累计值":
        return x1.pr6;
        break;
      case "12小时累计值":
        return x1.pr12;
        break;
      case "24小时累计值":
        return x1.pr24;
        break;
      case "48小时累计值":
        return x1.pr48;
        break;
      case "72小时累计值":
        return x1.pr72;
        break;
    }
    return x1.pr24;
  }

  static Widget getRainPanel(ScqxR x1) {
    List<Widget> list1 = <Widget>[];

    List<Widget> list4 = <Widget>[];

    var ShowColor1 = Colors.blue;

    print(x1.toJson());
    list1.add(InputWidget.getGreyInfo2(x1.sname! + "站累计降雨量", "单位：mm"));

    var v1 =
        InputWidget.getShowInfo("1小时", x1.pr1.toStringAsFixed(1), ShowColor1);
    var v2 =
        InputWidget.getShowInfo("6小时", x1.pr6.toStringAsFixed(1), ShowColor1);
    var v3 =
        InputWidget.getShowInfo("12小时", x1.pr12.toStringAsFixed(1), ShowColor1);
    var v4 =
        InputWidget.getShowInfo("24小时", x1.pr24.toStringAsFixed(1), ShowColor1);
    var v5 =
        InputWidget.getShowInfo("48小时", x1.pr48.toStringAsFixed(1), ShowColor1);
    var v6 =
        InputWidget.getShowInfo("72小时", x1.pr72.toStringAsFixed(1), ShowColor1);

    list4.add(InputWidget.getDivider());
    list4.add(InputWidget.getShowRow([v1, v2, v3], true));
    list4.add(InputWidget.getDivider());
    list4.add(InputWidget.getShowRow([v4, v5, v6], true));
    list4.add(InputWidget.getDivider());
    list1.add(InputWidget.inCard3(list4));
    list1.add(Container(height: 6.0));
    return InputWidget.inCard3(list1);
  }

  static Widget getSKTimeLine2(List<DayData> zList, String cs) {
    List<String> tList = <String>[];
    List<double> vList = <double>[];
    String dw = "-";

    for (var a in zList) {
      tList.add(Helper.DateTimeFormat5(a.TM));
      switch (cs) {
        case "日均水位":
          {
            vList.add(a.AverH1);
            dw = "m";
          }
          break;
        case "日均入库":
          {
            vList.add(a.AverR);
            dw = "m3/s";
          }
          break;
        case "日均出库":
          {
            vList.add(a.AverQz);
            dw = "m3/s";
          }
          break;
        case "日均发电量":
          {
            vList.add(a.ZFdL);
            dw = "万kW.h";
          }
          break;
        case "日均降雨量":
          {
            vList.add(a.AverP);
            ;
            dw = "mm";
          }
          break;
      }
    }
    // print(vList);

    return TimeLinePanel(cs + "过程线", tList, vList, zList.length, 2, dw);
  }
}
